package com.angus.api.front;


import com.angus.api.front.domain.FrontSendCode;
import com.angus.api.front.domain.FrontUser;
import com.angus.api.front.factory.RemoteFrontUserFallbackFactory;
import com.angus.api.front.model.FrontLoginUser;
import com.angus.api.front.model.FrontUserStatistics;
import com.angus.common.core.constant.SecurityConstants;
import com.angus.common.core.constant.ServiceNameConstants;
import com.angus.common.core.domain.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient(contextId = "remoteFrontUserService", value = ServiceNameConstants.FRONT_SERVICE, fallbackFactory = RemoteFrontUserFallbackFactory.class)
public interface RemoteFrontUserService {


    /**
     * 通过用户名查询用户信息
     *
     * @param username 用户名
     * @param source 请求来源
     * @return 结果
     */
    @GetMapping("/front/user/info/{username}")
     R<FrontLoginUser> getUserInfo(@PathVariable("username") String username, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 注册用户信息
     *
     * @param frontUser 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PostMapping("/front/user/register")
     R<Boolean> registerUserInfo(@RequestBody FrontUser frontUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);



    /**
     * 记录用户登录IP地址和登录时间
     *
     * @param frontUser 用户信息
     * @param source 请求来源
     * @return 结果
     */
    @PutMapping("/front/user/recordLogin")
     R<Boolean> recordUserLogin(@RequestBody FrontUser frontUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过手机号查询用户信息
     */
    @GetMapping("/front/user/selectUserByPhoneNum/{device}")
    R<FrontLoginUser> selectUserByPhoneNum(@PathVariable("device") String device,@RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    /**
     * 通过设备查询用户信息
     */
    @GetMapping("/front/user/selectUserByDevice/{device}/{type}")
    R<FrontLoginUser> selectUserByDevice(
            @PathVariable("device") String device,
            @PathVariable("type") Integer type,
            @RequestHeader(SecurityConstants.FROM_SOURCE) String source
    );


    /**
     * 查询用户最后发送的验证码
     */
    @GetMapping("/front/user/queryLastSendCode")
    R<FrontSendCode> queryLastSendCode(
            @RequestParam(value = "device") String device,
            @RequestParam(value = "sceneCode",required = false)Integer sceneCode,
            @RequestParam(value = "dateTime", required = false)String dateTime,
            @RequestHeader(SecurityConstants.FROM_SOURCE) String source
    );

    /**
     * 保存验证码
     */
    @PostMapping("/front/user/saveSendCode")
    R<Boolean> saveSendCode(@RequestBody FrontSendCode newSendCode, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 更新验证码信息
     */
    @PutMapping("/front/user/updateSendCode")
    R<Boolean> updateSendCode(@RequestBody FrontSendCode newSendCode, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 密码重置
     */
    @PutMapping("/front/user/passwordRest")
    R<Boolean> passwordRest(@RequestBody FrontUser frontUser, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);

    /**
     * 通过邮箱查询用户信息
     */
    @PostMapping("/front/user/findUserByEmail")
    R<FrontLoginUser> findUserByEmail(String email, @RequestHeader(SecurityConstants.FROM_SOURCE) String source);


    @GetMapping("/front/user/getUserInfoCount")
    R<FrontUserStatistics> getUserInfoCount(@RequestHeader(SecurityConstants.FROM_SOURCE) String source);
}
